<%-- 
    Document   : consulta_turma
    Created on : 03/12/2011, 12:38:33
    Author     : leonardo
--%>

<%@page import="br.com.ufpb.halloc.negocio.Turma"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.util.Collections"%>
<%@page import="javax.swing.JOptionPane"%>
<%@page import="br.com.ufpb.halloc.comunicacao.Facade"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
        <style type="text/css">
            div#back {
                background-color: lightsteelblue;
                height: auto;
                margin-top: 0px;
                margin-left: 170px;
                margin-right: 170px;
            }
            div#form {
                background-color: #DDD;
                font: 14px Verdana, sans-serif;
                height: 60px;
                margin-top: 5px;
                border: 1px solid #696969;
                margin-left: 100px;
                margin-right: 100px;
            }
            
            div#campos, div#form {
                color: #333;
            }
                
            #tab_customizada
            {
                font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
                width:100%;
                border-collapse:collapse;
            }
            #tab_customizada td, #tab_customizada th 
            {
                font: 14px Verdana, sans-serif;
                border:2px solid #98bf21;
                padding:3px 7px 2px 7px;
                color: #000000;
            }
            #tab_customizada th 
            {
                font: 16px Verdana, sans-serif;
                text-align:center;
                padding-top:5px;
                padding-bottom:4px;
                background-color:#369;
                color:#fff;
            }
            #tab_customizada tr.alt td 
            {
                color:#000000;
                background-color: #EAF2D3;
            }

        </style>
        <script language="JavaScript" type="text/javascript">
            function confirmacao(id, nome){
                var opcao = confirm('Você tem certeza que deseja remover a Turma:\n' + nome + '?')
                if (opcao) {
                    window.self.location.href = "RemoveTurma?codigo="+id;                    
                }
            }
        </script>
    </head>
    <body>
        <jsp:include page="menubarra.jsp"></jsp:include>        
        <br>
        <form action="ConsultaTurma" method="POST" id="consulta">
            <div id="back">
                <br>
                <h3 align="center">CONSULTA TURMA</h3>
                <div align="center">Realize aqui suas consultas e atualizações nas Turmas cadastradas</div>
                <div id="form">
                    <br>
                    <table width="60%" align="center">
                        <tr>
                            <td><font size="4" face="arial"> Código: </font></td>
                            <td><input type="text" name="cod_turma" size="10"></td>
                            <td><font size="4" face="arial"> Nome: </font></td>
                            <td><input type="text" name="nome_turma" size="40"></td>
                        </tr>
                    </table>
                </div>
                <div align="center">
                    <br>
                    <table>
                        <tr>
                            <td colspan="2"><input type="submit" value="Consultar"></td>
                        </tr>
                    </table>
                </div>
            <br>
         <div align="center"> 
           <br>
             <table id="tab_customizada" border="1">
                    <tr>
                        <th>Código</th>
                        <th>Nome</th>
                        <th>Disciplina</th>
                        <th>Ações</th>
                    </tr>
                    <% //buscar disciplinas cadastradas
                    List<Turma> turmas = new ArrayList<Turma>();
        
                    turmas = (List<Turma>) request.getAttribute("consulta");
        
                    if (turmas != null) {
                        for (Turma t : turmas) { %>
                            <tr>
                                <td><%=t.getCodTurma()%></td>
                                <td><%=t.getNomeTurma()%></td>
                                <td><%=t.getCodDisciplina()%> </td>
                                <td>
                                    <a href="#" onclick="window.open('AtualizaTurma.jsp?codigo=<%=t.getCodTurma()%>&nome=<%=t.getNomeTurma()%>', 'Atualizar Disciplina', 'STATUS=NO, TOOLBAR=NO, LOCATION=NO, DIRECTORIES=NO, RESISABLE=NO, SCROLLBARS=YES, TOP=200, LEFT=400, WIDTH=500, HEIGHT=300');">
                                        <img name="" src="imagens/atualizar.png" width="30" height="30" alt="atualiza"/>
                                    </a>
                                        <img name="" onclick="confirmacao('<%=t.getCodTurma()%>', '<%=t.getNomeTurma()%>')" src="imagens/remover.png" width="30" height="30" alt="remove"/>
                                </td>
                            </tr>
                  <%    } // fim do for 
                     } // fim do if   
                  %>
             </table>
             <br>
    </body>
</html>
